import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
import { Task, TaskType } from '../entity/Task';
import { UIManager } from '../common/UIManager';
import { OtherTaskItem } from './OtherTaskItem';
import { MainTaskItem } from './MainTaskItem';
const { ccclass, property } = _decorator;

@ccclass('OtherTask')
export class OtherTask extends Component {

    @property(Node)
    content:Node
    @property(Prefab)
    mainTaskItem:Prefab

    async start() {
        await UIManager.instance.showLoading()
        let list = await Task.getTaskListByType(TaskType.Other)
        UIManager.instance.closeLoading()
        console.log(list)

        for(let item of list){
            let node = instantiate(this.mainTaskItem)
            this.content.addChild(node)
            node.getComponent(MainTaskItem).setData(item)
          }
     }

    update(deltaTime: number) {
        
    }
}


